package chapter03

import org.apache.spark.{SparkConf, SparkContext}

object Test03_RDD {
  def main(args: Array[String]): Unit = {
    //创建RDD
    val conf = new SparkConf().setMaster("local[*]").setAppName("create")
    val sc = new SparkContext(conf)
    //直接创建
    val value = sc.makeRDD(List(1, 2, 3, 4, 5, 6))
    val value1 = sc.parallelize(List(("abc",1),("bcd"->2)))
    println(value.collect().mkString("Array(", ", ", ")"))
    //通过文件直接创建
    val value2 = sc.textFile("input/word.txt")
    println(value2.collect().toList)
    //关闭上下文
    sc.stop()
  }
}
